#include <sheet/include/sheet.h>
#include <iostream>
#include <iomanip>
#include <windows.h>
#	pragma comment(lib, "sheet.lib")
#	pragma comment(lib, "common.lib")
#	pragma comment(lib, "file.lib")

void PrintEntry(excel::entry* e)
{
	excel::sheet* s = e->get_sheet();
	int c = s->get_column_count();
	for (int i = 0; i != c; i++)
	{
		excel::cell* c = e->get_cell(i);
		int type = s->get_type(i);
		switch (type)
		{
		case excel::cv_id:
		case excel::cv_int:
			std::cout << std::setw(10) << c->to_int();
			break;
		case excel::cv_float:
			std::cout << std::setw(10) << c->to_float();
			break;
		case excel::cv_str:
			std::wcout << std::setw(10) << c->to_wstring();
			break;
		}
	}
	std::cout << std::endl;
}
void main()
{
	setlocale(LC_ALL, "chs");


	excel::sheet* s = excel::load_sheet("..\\res\\sheet.txt");
	if (s)
	{
		int count = s->get_column_count();
		for (int i = 0; i != count; i++)
		{
			std::wcout << std::setw(10) << s->get_title(i);
		}
		std::wcout << std::endl;
		excel::entry_iterator* eb = s->first();
		excel::entry_iterator* ee = s->last();

		while (!eb->is_equal(ee))
		{
			excel::entry* e = eb->get_entry();

			PrintEntry(e);
			eb->next();
		}

		s->release();
	}
}